<h1>Listing posts</h1>

<table>
    <tr>
        <th>Name</th>
        <th>Title</th>
        <th>Content</th>
        <th>Author</th>
        <th></th>
        <th></th>
        <th></th>
        <th></th>
    </tr>

    <% @posts.each do |post| %>
        <tr>
            <td><%= post.name %></td>
            <td><%= post.title %></td>
            <td><%= post.content %></td>
            <td><%= post.user.username %></td>
            <td><%= link_to 'Show', post %></td>
            <% if post.user.username == @currentUser.username %>
                <td><%= link_to 'Edit', edit_post_path(post) %></td>
                <td><%= link_to 'Destroy', post, method: :delete, data: {confirm: 'Are you sure?'} %></td>
            <% end %>
        </tr>
    <% end %>
</table>

<br/>

<%= link_to 'New Post', new_post_path %>
